<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta name="viewport" content="width=device-width"/>
    <title>通讯录</title>
    <script th:src="@{/js/jquery-1.9.1.min.js}"></script>
    <script th:src="@{/js/fenYe.js}"></script>

    <script th:src="@{/js/bootstrap.js}"></script>
    <link th:href="@{/css/bootstrap.css}" rel="stylesheet"/>

    <script th:src="@{/js/bootstrap-table.js}"></script>
    <link th:href="@{/css/bootstrap-table.css}" rel="stylesheet"/>

    <link th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
    <script th:src="@{/js/bootstrap-table-zh-CN.js}"></script>

</head>
<body onload="fenye_init();">
<div class="panel-body" style="padding-bottom:0px;">
    <div class="panel panel-default">
        <div class="panel-heading">查询条件</div>
        <div class="panel-body">
            <form id="formSearch" class="form-horizontal">
                <div class="form-group" style="margin-top:15px">
                    <label class="control-label col-sm-1" for="type">部门名称</label>
                    <div class="col-sm-3">
                        <input type="text" class="form-control" id="type">
                    </div>
                    <div class="col-sm-4" style="text-align:left;">
                        <button type="button" onclick="fenye_init();" style="margin-left:50px"  class="btn btn-primary">查询
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <div id="toolbar" class="btn-group">
        <button onclick="window.location.href='/user/add'" id="btn_add" type="button" class="btn btn-default">
            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
        </button>
        <button id="btn_edit" type="button" class="btn btn-default">
            <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>修改
        </button>
        <button id="btn_delete" type="button" class="btn btn-default">
            <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
        </button>
    </div>
    <table id="taskInfo"></table>

    <script>
        $("#btn_delete").on("click",function (){
            var row=$("#taskInfo").bootstrapTable('getSelections');
            console.log(row);
            var userid = row[0].id;
            if (!userid) {
                alert("请先选选中一行");
                return;
            }
            if (userid == 1) {
                alert("这个是登录用户.别删!");
                return;
            }
            $.post("/user/del", {userid, userid}, function (result) {
                console.log(result);
                $('#taskInfo').bootstrapTable('refresh', {pageSize:10});
            }, 'json');


        })


        $("#btn_edit").on("click",function (){
            var row=$("#taskInfo").bootstrapTable('getSelections');
            console.log(row);
            var userid = row[0].id;
            if (!userid) {
                alert("请先选选中一行");
                return;
            }
            window.location.href = "/user/update?userid=" + userid;


        })
    </script>
</div>
</body>
</html>